<?php

// load library
require_once('../include/GeneralTop.php');
require('../include/class/db.php');
require('../include/lib/php_excel/php-excel.class.php');

if (!$super_admin) {
	die('<div style="text-align:center">Permission denied...</div>');
}

$db = new db;
switch ($_GET['action']) {
	case 'member':
		//$data = "id\tlogin\t姓名\t性别\t身份证号\t电话\t手机\tEmail\t地址\t区\t邮编\t职业\t是否有宠物\t宠物类型\t宠物品种\t宠物数\t是否愿意成为付费会员\t付费会员开始日期\t付费会员结束日期\t会员状态\t会员类型\t是否愿意成为志愿者\t志愿者类型\t外语能力\t是否愿意免费寄养宠物\t可寄养何种宠物\t有偿寄养宠物价格\t兴趣\t经验\t注册日期\n\r";
		$data[] = array("id", "login", "姓名", "性别", "身份证号", "电话", "手机", "Email", "地址", "区", "邮编", "职业", "是否有宠物", "宠物类型", "宠物品种", "宠物数", "是否愿意成为付费会员", "付费会员开始日期", "付费会员结束日期", "会员状态", "会员类型", "是否愿意成为志愿者", "是否救助志愿者", "是否寄养志愿者", "是否运输志愿者", "是否活动策划志愿者", "是否网站志愿者", "是否助养志愿者", "外语能力", "是否愿意免费寄养宠物", "可寄养何种宠物", "有偿寄养宠物价格", "兴趣", "经验", "注册日期");
		$res = $db->query("SELECT * FROM member_info ORDER BY register_date DESC");
		while($row = $db->fetch($res)) {
			//$data .= $row['member_id']."\t".$row['member_login']."\t".$row['member_name']."\t".$row['Sex']."\t".$row['Identity_id']."\t".$row['Phone_number1']."\t".$row['Phone_number2']."\t".$row['Email_account']."\t".$row['Address']."\t".$row['Distict']."\t".$row['Zip']."\t".$row['profession_type']."\t".$row['Pet_YN']."\t".$row['Pet_type']."\t".$row['Pet_breed']."\t".$row['Pet_count']."\t".$row['be_pay_member_YN']."\t".$row['Member_startDate']."\t".$row['Member_endDate']."\t".$row['Member_Status']."\t".$row['Member_type']."\t".$row['Volunteer_YN']."\t".$row['Volunteer_Type']."\t".$row['foreign_language']."\t".$row['foster_fee_YN']."\t".$row['foster_type']."\t".$row['foster_fee_amount']."\t".$row['interest_skills']."\t".$row['Experience']."\t".$row['register_date']."\n\r";
			$type1 = '否';
	  	    $type2 = '否';
	  	    $type3 = '否';
	  	    $type4 = '否';
	  	    $type5 = '否';
	  	    $type6 = '否';
			$vol_type = explode(",", $row['Volunteer_Type']);
		    if(in_array(1, $vol_type)) {
		      	$type1 = '是';
		    }
		    if(in_array(2, $vol_type)) {
		      	$type2 = '是';
		    }
		    if(in_array(3, $vol_type)) {
		      	$type3 = '是';
		    }
		    if(in_array(4, $vol_type)) {
		      	$type4 = '是';
		    }
		    if(in_array(5, $vol_type)) {
		      	$type5 = '是';
		    }
		    if(in_array(6, $vol_type)) {
		      	$type6 = '是';
		    }
			$data[] = array($row['member_id'], $row['member_login'], $row['member_name'], getMemberSex($row['Sex']), $row['Identity_id'], $row['Phone_number1'], $row['Phone_number2'], $row['Email_account'], $row['Address'], $row['Distict'], $row['Zip'], $row['profession_type'], getIfHavePet($row['Pet_YN']), getPetType($row['Pet_type']), $row['Pet_breed'], $row['Pet_count'], getIfPaid($row['be_pay_member_YN']), $row['Member_startDate'], $row['Member_endDate'], getMemberStatus($row['Member_Status']), getMemberType($row['Member_type']), getIfVolunteer($row['Volunteer_YN']), $type1, $type2, $type3, $type4, $type5, $type6, $row['foreign_language'], getIfFreeFoster($row['foster_fee_YN']), getPetType($row['foster_type']), $row['foster_fee_amount'], $row['interest_skills'], $row['Experience'], $row['register_date']);
		}
		break;
}

// generate file (constructor parameters are optional)
$xls = new Excel_XML('UTF-8', false, 'Member Info');
$xls->addArray($data);
$xls->generateXML('member_info');

?>